package com.bms.admin.bussiness.member.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.bms.admin.base.index.model.NowUser;
import com.bms.admin.config.annotation.LoginUser;
import com.bms.auth.annotation.RequiresPermissions;
import com.bms.common.base.common.bean.Result;
import com.bms.common.base.web.BaseController;
import com.bms.common.bussiness.member.entity.MemberInfo;
import com.bms.common.bussiness.member.service.IMemberInfoService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author JIANG
 */
@RestController
@RequestMapping("memberInfo")
@Api(value="memberInfo-Api",tags="会员信息卡接口")
public class MemberInfoController extends BaseController{
	
	@Autowired
	private IMemberInfoService memberInfoService;
	
	
	@ApiOperation("会员信息卡列表")
	@GetMapping("list")
	@RequiresPermissions("memberInfo:list")
    public Result list(@ApiIgnore @LoginUser NowUser nowUser,
    				  @RequestParam(defaultValue = "1",required=false)Integer pageNum,
    				  @RequestParam(defaultValue = "20",required=false)Integer pageSize,
    				  @RequestParam("openId") String openId) {
		EntityWrapper<MemberInfo> ew = new EntityWrapper<>();
		ew.orderBy("create_time", false);
		ew.eq("open_id", openId);
		return json(memberInfoService.selectPage(new Page<MemberInfo>(pageNum,pageSize),ew));
    }
	
	
}
